﻿@using ECG.Common
@using ECG.Utility
@using ECG.WebUI.CustomHelpers
<div class="mnu-box">
    @{
        var grandParentList = from c in ((List<ProductCategoryDto>)ViewBag.Menu) where c.ParentId == "0" orderby c.Ordering select c;
        var dem = 0;
        var bannerList = (List<ProductCategoryBannerWidthDto>)ViewBag.Banner;
        //var providerList = (List<ProviderDto>)ViewBag.Provider;
    }
    <div id="mnu-plc-header">
        <div class="home-layout mnu-header">
            <a href="javascript:void(0)" rel="nofollow">
                <span class="home-layout mnu-arrow"></span>
                DANH MỤC SẢN PHẨM
            </a>
        </div>
    </div>
    <div class="mnu-list">
        <ul class="mnu-item ul">
            @foreach (var grandParent in grandParentList)
            {
                dem++;
                <li>
                    <h2>
                        <a href="@Url.Action("Index", "CategoryL1", new { categoryName = StringUtil.RemoveSpecialCharactersVn(grandParent.Name), categoryId = grandParent.Id })">
                            <span class="icon-@grandParent.Icon"></span>
                            @grandParent.Name
                        </a>
                    </h2>
                    @{
                var parentList = from m in (List<ProductCategoryDto>)ViewBag.Menu where m.ParentId == grandParent.Id orderby m.Ordering select m;
                    }
                    @if (parentList.Any())
                    {
                        var countl1 = 0;
                        <!--Sub menu-->
                        <div class="mnu-sub-box">
                            <div class="mnu-box-wrap">
                                <!--image category avatar-->
                                @{
                                    var bannerCate = (from b in bannerList where b.Id == grandParent.Id select b).SingleOrDefault();
                                    if (bannerCate != null)
                                    {
                                        <img src="@bannerCate.ImagePath.ImagePathThumbDefault()" width="@bannerCate.Width" height="@bannerCate.Height" alt="@bannerCate.Description" class="imgCategoryHome" />
                                    }
                                }
                                <div class="mnu-padding">
                                    <div class="mnu-caption">
                                        <div class="clearfix" style="width: 100%; position: relative;">
                                            <span class="fl">@grandParent.Name</span>
                                            @if (dem == 1)
                                            {
                                                <span class="ds-file">
                                                    <a href="/Danh-sach-do-so-sinh-cho-be.doc" rel="nofollow">Download danh sách đồ sơ sinh</a>
                                                </span>
                                            }
                                            <span class="fr"><a href="">Thương hiệu nổi bật</a></span>
                                        </div>
                                    </div>
                                    <div class="mnu-body clearfix">
                                        <ul class="mnu-sub-box-1 ul">
                                            <li>
                                                @foreach (var parent in parentList)
                                                {
                                                    countl1++;

                                                    <h3><a href="@Url.Action("Index", "Category", new { categoryName = StringUtil.RemoveSpecialCharactersVn(parent.Name), categoryId = parent.Id })">@parent.Name</a></h3>
                                                    var parentList4 = from m in (List<ProductCategoryDto>)ViewBag.Menu where m.ParentId == parent.Id orderby m.Ordering select m;
                                                    if (parentList4.Any())
                                                    {
                                                        foreach (var item in parentList4)
                                                        {
                                                            countl1++;
                                                            <h4><a href="@Url.Action("Index", "CategoryL3", new { categoryName = StringUtil.RemoveSpecialCharactersVn(item.Name), categoryId = item.Id })">@item.Name</a></h4>
                                                            if (countl1 == 10)
                                                            {
                                                                @Html.Raw("</li></ul><ul class='mnu-sub-box-1 ul'><li>")
                                                            }
                                                        }
                                                    }
                                                    if (countl1 == 9)
                                                    {
                                                        @Html.Raw("</li></ul><ul class='mnu-sub-box-1 ul'><li>")
                                                    }
                                                }
                                            </li>
                                        </ul>

                                        <!--Provider by cate menu-->
                                        @Html.Action("GetProviderForMenu", "Home", new { categoryId = grandParent.Id })
                                    </div>

                                </div>
                                <div class="mnu-footer clearfix">
                                    <ul class="mnu-footer-list ul">
                                        <li><a href="">Sản phẩm mới</a></li>
                                        <li><a href="">Sản phẩm mua nhiều</a></li>
                                        <li><a href="">Sản phẩm giảm giá</a></li>
                                        <li><a href="">Sản phẩm xem nhiều</a></li>
                                        <li><a href="" class="lnkHangthanhly">Hàng thanh lý</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <!--End Sub menu-->
                    }

                </li>
            }

        </ul>
    </div>
</div>
